package com.neusoft.hifly.core.token.domain;

import java.io.Serializable;

import org.apache.commons.lang3.StringUtils;

import com.neusoft.hifly.commons.lang.StringConstants;

/**
 * JSON Web Token信息
 */
public class TokenVO implements Serializable {

	private static final long serialVersionUID = -2191556204630491224L;

	// Token
	private String token;

	// 用户ID
	private String userId;

	// 用户登录名
	private String loginName;

	// 用户名
	private String userName;

	// 医院ID，多个逗号分隔
	private String hospitals;

	// 科室ID，多个逗号分隔
	private String departments;

	// 区域ID，多个逗号分隔
	private String regions;

	/**
	 * 获取一个医院（主医院）
	 * 
	 * @return 主医院
	 */
	public String getHospital() {
		if (StringUtils.isEmpty(this.getHospitals())) {
			return null;
		}
		final String[] idArr = this.getHospitals().split(StringConstants.STRING_SPLIT_FLAG_3);
		if (idArr == null) {
			return null;
		}
		return idArr[0];
	}

	/**
	 * 获取一个科室（主科室）
	 * 
	 * @return 主科室
	 */
	public String getDefDepartment() {
		if (StringUtils.isEmpty(this.getDepartments())) {
			return null;
		}
		final String[] idArr = this.getDepartments().split(StringConstants.STRING_SPLIT_FLAG_3);
		if (idArr == null) {
			return null;
		}
		return idArr[0];
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getHospitals() {
		return hospitals;
	}

	public void setHospitals(String hospitals) {
		this.hospitals = hospitals;
	}

	public String getDepartments() {
		return departments;
	}

	public void setDepartments(String departments) {
		this.departments = departments;
	}

	public String getRegions() {
		return regions;
	}

	public void setRegions(String regions) {
		this.regions = regions;
	}
}
